package com.cos.lession71.slice;

import com.cos.lession71.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class NewPageAbilitySlice extends AbilitySlice {

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        setUIContent(ResourceTable.Layout_ability_new_page);
        //获取按钮
        Button b = (Button) findComponentById(ResourceTable.Id_btn3);
        //设置点击 监听

        b.setClickedListener(new Component.ClickedListener() {
            @Override
            public void onClick(Component component) {
                Operation build = new Intent.OperationBuilder()
                        .withDeviceId("")//设置设备id 没有设置直接设置为""
                        //.withBundleName("com.cos.lessionhm")
                        .withBundleName(getBundleName())
                        .withAbilityName(".NextAbilitySlice")
                        .build();
                Intent i= new Intent();
                i.setOperation(build);
                startAbility(i);
            }
        });

    }
}
